/*
 * @Author: Jimmy
 * @LastModifiedBy: Jimmy
 * @Date: 2024-05-25 19:29:07
 * @LastEditTime: 2024-09-05 20:46:03
 * @FilePath: /nest_study/server/src/modules/system/menu/menu.controller.ts
 */
import { Controller, Get, Post, Body, Delete, Put, Query, Request } from '@nestjs/common';
import { MenuService } from './menu.service';
import { CreateMenuDto, DeleteMenuDto, QueryMenuDto, UpdateMenuDto } from './dto/index.dto';
import { ApiBearerAuth, ApiBody, ApiOperation, ApiTags } from '@nestjs/swagger';

@ApiTags('菜单管理')
@ApiBearerAuth()
@Controller('system/menu')
export class MenuController {
  constructor(private readonly menuService: MenuService) { }

  @ApiOperation({
    summary: '菜单列表'
  })
  @ApiBody({
    type: QueryMenuDto,
    required: true
  })
  @Get('/list')
  findAll(@Query() query: QueryMenuDto) {
    return this.menuService.query(query);
  }

  @ApiOperation({
    summary: '创建菜单'
  })
  @ApiBody({
    type: CreateMenuDto,
    required: true
  })
  @Post('/create')
  create(@Body() createMenuDto: CreateMenuDto, @Request() req) {
    return this.menuService.create(createMenuDto);
  }

  @ApiOperation({
    summary: '菜单删除'
  })
  @ApiBody({
    type: UpdateMenuDto,
    required: true
  })
  @Put('/update')
  update(@Body() updateMenuDto: UpdateMenuDto, @Request() req) {
    return this.menuService.update(updateMenuDto);
  }

  @ApiOperation({
    summary: '菜单删除'
  })
  @ApiBody({
    type: DeleteMenuDto,
    required: true
  })
  @Delete('/delete')
  remove(@Body() info: DeleteMenuDto) {
    return this.menuService.remove(info);
  }
}
